#include<bits/stdc++.h>

using namespace std;
const int MOD = 1000000;

int main() {
    int n;
    cin >> n;
    if (n > 25)n = 25;
    int s = 0, p = 1;
    for (int i = 1; i <= n; i++) {
        p = (p * i) % MOD;
        s = (s + p) % MOD;


    }
    cout << s;

    return 0;
}